<?php
namespace app\admin\controller;
use app\common\controller\AdminBase;

/*用于提供公共hearders 和 bottoms 和left 部分*/
class Frame extends AdminBase
{
	/*头部*/
    public function headers()
    {
    	return $this->fetch();
    }
	/*尾部*/
	public function bottoms()
    {
    	return $this->fetch();
    }
	/*左边菜单*/
	public function left(){
		return $this->fetch();
	}
	/*顶部*/
	 public function top(){
	 	return $this->fetch();
	 }
	 /*内容部分*/
	 public function content(){
	 	return $this->fetch();
	 }
	 /*公共脚本部分*/
	 public function scripts(){
	 	return $this->fetch();
	 }
	 ///////////////////////////////////////////
	
	public function getstatistic(){
		$shop_id=sp_get_current_shop_id();
		$where_and=" ";
		if(!empty($shop_id)){
			$where_and.=" and shop_id=$shop_id";
		}
		$shop=db("shop")->find($shop_id);
		
		$data=date('Y-m-d');
		$result=array('div1'=>0,'div2'=>0,'div3'=>0,'div4'=>0);
		$result['div4']=db("Interface")->where("owner_type=1 and is_original=1 $where_and")->count(1);
		$result['div3']=db("Interface")->where("owner_type=2 and is_original=1 $where_and")->count(1);		
		$result['div2']=db('BehaviorLog')->where("behavior_status=1 and behavior_type=1 and date_format(create_time,'%Y-%m-%d')='$data' $where_and")->count("distinct(card_no)");
		$result['div1']=db('BehaviorLog')->where("behavior_status=1 and behavior_type=1 and date_format(create_time,'%Y-%m-%d')='$data' $where_and")->count(1);
		$result['shop_name']=$shop['shop_name']."<small>(".$shop['api_version'].")</small>";
		return $this->ajax_success($result);						
	}
}
